<template>
  <!-- 雷达图  图表必须给高和宽度-->
  <div ref="myDiv" class="radar-echart" />
</template>

<script>
// echarts的按需引入
import * as echarts from 'echarts/core'
import {
  TitleComponent,
  LegendComponent
} from 'echarts/components'
import {
  RadarChart
} from 'echarts/charts'
import {
  CanvasRenderer
} from 'echarts/renderers'

echarts.use(
  [TitleComponent, LegendComponent, RadarChart, CanvasRenderer]
)
export default {
  data() {
    return {
      option: {
        title: {
          text: '绩效雷达图'
        },
        legend: {
          data: ['平均水平', '个人价值']
        },
        radar: {
        // shape: 'circle',
          radius: '65%',
          center: ['50%', '50%'],
          axisName: {
            textStyle: {
              color: '#fff',
              backgroundColor: '#999',
              borderRadius: 3,
              padding: [3, 5]
            }
          },
          indicator: [
            { name: '工作效率', max: 100 },
            { name: '考勤', max: 100 },
            { name: '积极性', max: 100 },
            { name: '帮助同事', max: 100 },
            { name: '自主学习', max: 100 },
            { name: '正确率', max: 100 }
          ]
        },
        series: [{
          name: '平均 vs 个人',
          type: 'radar',
          data: [
            {
              value: [80, 80, 80, 80, 80, 80],
              name: '平均水平'
            },
            {
              value: [90, 75, 95, 90, 95, 90],
              name: '个人价值'
            }
          ]
        }]
      }
    }
  },
  mounted() {
    const myChart = echarts.init(this.$refs.myDiv)
    this.option && myChart.setOption(this.option)
  }
}
</script>

<style scoped>
.radar-echart {
    width: 600px;
    height: 400px;
}
</style>
